package cn.edu.jlu.grid.vjm;

import java.io.IOException;
import java.io.ObjectOutputStream;
import java.net.InetAddress;
import java.net.Socket;

public class VJobReleaseMessage extends VJMMessage{
	private InetAddress vjobAddress = null;
	private int vjobPort = -1;
	public VJobReleaseMessage(InetAddress addr, int p) {
		vjobAddress = addr;
		vjobPort = p;
	}
	public VJobReleaseMessage() {}
	public void onSend() {
		System.out.println("VJobReleaseMessage.onSend()");
		Socket socket = null;
		try {
			socket = new Socket(vjobAddress, vjobPort);
			ObjectOutputStream os = new ObjectOutputStream(socket.getOutputStream());
			os.writeObject(this);
			os.flush();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} finally {
			try { socket.close(); } catch (Exception e) {}
		}
	}
	public void onReceive(Socket connection) {
		System.exit(0);
		//VJobExecute.getInstance().dispose();
	}
	public String toString() {
		return "VJobReleaseMessage received";
	}
}
